#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@Author: Lidi
@Time  : 2019/11/13 7:59
@Desc  : pdb调试
"""
import pdb

'''
# 说明
# 参考：https://docs.python.org/3/library/pdb.html#module-pdb
打印 - p
继续执行到下一行 - n
打印当前代码上下11行 - l
进去相应代码 - s
    进入函数内部，显示`--Call--`
    出来时候显示`--Return--`
跳出当前代码 - r
给103行打断点 - b 103
持续运行，直到遇到下一个断点


# 使用
> e:\myfolder\learnpython\jx_python\31_debug_pdb.py(18)<module>()
-> func()
(Pdb) l
 13  	
 14  	
 15  	a = 1
 16  	b = 2
 17  	pdb.set_trace()
 18  ->	func()
 19  	c = 3
 20  	print(a + b + c)
[EOF]
(Pdb) p func
<function func at 0x000001E2FD842F28>
(Pdb) s
--Call--
> e:\myfolder\learnpython\jx_python\31_debug_pdb.py(11)func()
-> def func():
(Pdb) l
  6  	@Desc  : pdb调试
  7  	"""
  8  	import pdb
  9  	
 10  	
 11  ->	def func():
 12  	    print('hello world!')
 13  	
 14  	
 15  	a = 1
 16  	b = 2
(Pdb) n
> e:\myfolder\learnpython\jx_python\31_debug_pdb.py(12)func()
-> print('hello world!')
(Pdb) n
hello world!
--Return--
> e:\myfolder\learnpython\jx_python\31_debug_pdb.py(12)func()->None
-> print('hello world!')
(Pdb) l
  7  	"""
  8  	import pdb
  9  	
 10  	
 11  	def func():
 12  ->	    print('hello world!')
 13  	
 14  	
 15  	a = 1
 16  	b = 2
 17  	pdb.set_trace()
(Pdb) n
> e:\myfolder\learnpython\jx_python\31_debug_pdb.py(19)<module>()
-> c = 3
(Pdb) p c
*** NameError: name 'c' is not defined
(Pdb) l
 14  	
 15  	a = 1
 16  	b = 2
 17  	pdb.set_trace()
 18  	func()
 19  ->	c = 3
 20  	print(a + b + c)
[EOF]
(Pdb) n
> e:\myfolder\learnpython\jx_python\31_debug_pdb.py(20)<module>()
-> print(a + b + c)
(Pdb) p c
3
(Pdb) n
6
--Return--
> e:\myfolder\learnpython\jx_python\31_debug_pdb.py(20)<module>()->None
-> print(a + b + c)

> e:\myfolder\learnpython\jx_python\31_debug_pdb.py(102)<module>()
-> func()
(Pdb) b 104
Breakpoint 1 at e:\myfolder\learnpython\jx_python\31_debug_pdb.py:104
(Pdb) c
hello world!
> e:\myfolder\learnpython\jx_python\31_debug_pdb.py(104)<module>()
-> print(a + b + c)
(Pdb) l
 99  	a = 1
100  	b = 2
101  	pdb.set_trace()
102  	func()
103  	c = 3
104 B->	print(a + b + c)
105  	
106  	
[EOF]
(Pdb) n
6
--Return--
> e:\myfolder\learnpython\jx_python\31_debug_pdb.py(104)<module>()->None
-> print(a + b + c)
(Pdb) 
'''


def func():
    print('hello world!')


a = 1
b = 2
pdb.set_trace()
func()
c = 3
print(a + b + c)


